<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <input type="button" value="节流" onclick="jieliu()" />

    <script>
        function digui(n) {
            if (n === 1) return 1;
            return n * digui(n - 1)
        }
        console.log(digui(3));
        console.log('-----------------');

        let fangdou = null
            //节流：不管调用多少次，一定时间内只调用一次
        function jieliu() {
            if (fangdou) {
                return console.log(0)
            } else {
                fangdou = setTimeout(() => {
                    console.log(new Date())
                    fangdou = null
                }, 3000)
            }

        }
    </script>


</body>

</html>